package com.leetcode.weekly.contest.no284th;

/**
 * @author 覃国强
 * @date 2022-03-13 10:45
 */
public class A02_统计可以提取的工件 {

  static
  class Solution {
    public int digArtifacts(int n, int[][] artifacts, int[][] dig) {

      int[][] grids = new int[n][n];
      for (int[] curDig : dig) {
        grids[curDig[0]][curDig[1]] = 1;
      }

      int answer = 0;

      for (int[] artifact : artifacts) {
        boolean mark = true;
        for (int i = artifact[0]; i <= artifact[2] && mark; ++i) {
          for (int j = artifact[1]; j <= artifact[3] && mark; ++j) {
            if (grids[i][j] != 1) {
              mark = false;
            }
          }
        }
        answer += mark ? 1 : 0;
      }

      return answer;
    }
  }

}
